import { createApp } from 'vue';

import App from './App.vue';
import router from './router';
import { setupStore } from './store';
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'




import '@/styles/index.scss';
import SvgIcon from './icons'; // icon
import './permission'; // permission control
import vPermission from './directive/permission/index'; // permission control
import { checkEnableLogs } from './utils/error-log'; // error log
import mitt from 'mitt'

// const Mit = mitt()
const app = createApp(App);
setupStore(app);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
import eventBus from '@/utils/eventBus'
const getUrl = () => {
  return 'https://beta.paiduoduo.app/admin/v1/uploadImg'
}
const showUser = (id) => {
  console.log('全局方法---------')
  eventBus.emit('dialog', id)
  // return
}

// app.config.globalProperties.$EventBus = Mit
app.config.globalProperties.$upUrl = getUrl()
// app.config.globalProperties.showUser = showUser()
app.provide('showUser', showUser)

app.use(ElementPlus),
  app.use(router),
  app.component('svg-icon', SvgIcon),
  app.directive('permission', vPermission),
  checkEnableLogs(app),

  app.mount('#app');
